import { FC, useEffect, useState } from 'react'
import WebScreenShot from '@renderer/components/WebScreenShot'
const ScreenShot: FC = () => {
  const [base64, setBase64] = useState('')
  window.electron.ipcRenderer.on('watchscreenShot', (_, base64) => {
    setBase64(base64)
  })
  
  useEffect(() => {
    // 关闭透明窗口
    if (!base64) {
      const cutBoxSizePanels = document.querySelectorAll('#cutBoxSizePanel')
      cutBoxSizePanels.forEach((item) => item.remove())
      window.electron.ipcRenderer.send('closeScreenShot')
    }
  }, [base64])
  return <>{base64 && <WebScreenShot base64={base64} setBase64={setBase64} />}</>
}

export default ScreenShot
